var loading_tree_node=false;

function tree_view_onclick(id){
  try{
    if(!loading_tree_node){
      var parent_node=getElement("tree_node_"+id);
      var child_container=getElement("tree_node_childs_"+id);      
      if(!parent_node.loaded){
        child_container.className="tree_view_child_container_loading";
        parent_node.className="in_tree_view_loading";
        aGet(getURL("tree_view?execute=1&parent_id="+id),"tree_view_loaded");
        loading_tree_node=id;
      }else{        
        if(parent_node.className=="in_tree_view_loaded_full_opened"){
            child_container.className="tree_view_child_container_unloaded";
          parent_node.className="in_tree_view_loaded_full_closed";
        }else{
          if(parent_node.className=="in_tree_view_loaded_full_closed"){
            child_container.className="tree_view_child_container_loaded";
            parent_node.className="in_tree_view_loaded_full_opened";
          }
        }
      }
    }
  }catch(e){
    logging("Error tree_view_onclick:"+e.message);  
  }
}

function tree_view_loaded(content,xml){
  try{
    if(loading_tree_node){
      var parent_node=getElement("tree_node_"+loading_tree_node);
      var child_container=getElement("tree_node_childs_"+loading_tree_node);
      ///
      if(xml.responseText!=""){
        child_container.innerHTML=xml.responseText;
        parent_node.className="in_tree_view_loaded_full_opened";
        child_container.className="tree_view_child_container_loaded";
      }else{
        parent_node.className="in_tree_view_loaded_empty";
        child_container.className="tree_view_child_container_unloaded";
      }
      ///
      parent_node.loaded=true;
      loading_tree_node=false;
    }
  }catch(e){
    logging("Error tree_view_loaded:"+e.message);  
  }
}